{% extends '../../../layout/admin-base.html' %}
<script src="{{ assets_path("js/base.js")}}"></script>
{% block page %}
<h3 class="page-title">
    包厢信息 <small>列表</small>
</h3>
<ul class="breadcrumb">
    <li>
        <i class="icon-home"></i>
        <a href="index.html">基本信息管理</a> 
        <i class="icon-angle-right"></i>
    </li>
    <li>
        <a href="{{url('admin/user/student')}}">包厢信息管理</a>
        <i class="icon-angle-right"></i>
    </li>
    <li><span>列表</span></li>
</ul>
{% end%}
{% block content %}

<div class="row-fluid">
    <div class="span12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="icon-list"></i>包厢列表</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="#portlet-config" data-toggle="modal" class="config"></a>
                    <a href="javascript:;" class="reload"></a>
                    <!-- <a href="javascript:;" class="remove"></a> -->
                </div>
            </div>
            <div class="portlet-body">
                <div class="clearfix">
                    <div class="btn-group">
                        <a id="sample_editable_1_new" class="btn green" href="{{url('admin/food/box/new')}}">
                        增加<i class="icon-plus"></i>
                        </a>
                        <a id="status_ture" class="btn yellow">
                        使用中<i class="icon-ban-circle"></i>
                        </a>
                        <a id="status_false" class="btn blue">
                        空闲<i class="icon-ok"></i>
                        </a>
                    </div>
                    <div class="btn-group pull-right">
                        <button class="btn dropdown-toggle" data-toggle="dropdown">工具<i class="icon-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="#">打印</a></li>
                            <li><a href="#">另存为PDF</a></li>
                            <li><a href="#">另存为Excel</a></li>
                        </ul>
                    </div>
                </div>
                <table class="table table-striped table-bordered table-hover" id="sample_1">
                    <thead>
                        <tr>
                            <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                            <th class="hidden-480">包厢名</th>
                            <th class="hidden-200">备注</th>
                            <th class="hidden-200">状态</th>
                            <!-- <th class="hidden-200">所属食堂</th> -->
                            <th ></th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for i in data %}
                        <tr class="odd gradeX">
                            <td><input type="checkbox" class="checkboxes" value="{{ i['Fid'] }}" name="select" /></td>
                            <td>{{ i["Fname"] }}</td>
                            <td>{{ i["Fremark"] }}</td>
                            <td class="center hidden-100">
                                {% if i["Fstatus"]=='0' %}
                                    <span class="label label-success">空闲</span>
                                {% else %}
                                    <span class="label label-error">使用中</span>
                                {% end %}
                            </td>
                            <td><a class="btn mini purple" href="{{ reverse_url('box.edit', i['Fid']) }}">
                                    <i class="icon-edit"></i>编辑
                                </a>
                                <a class="btn mini black" href="{{ reverse_url('box.del_box', i['Fid'], page_info['page']) }}">
                                    <i class="icon-trash"></i>删除
                                </a>
                                <a class="btn mini blue" href="{{ reverse_url('box.set_status', i['Fid'], '0', page_info['page']) }}">
                                    <i class="icon-ok"></i>空闲
                                </a>
                                <a class="btn mini yellow" href="{{ reverse_url('box.set_status', i['Fid'], '1', page_info['page']) }}">
                                    <i class="icon-ban-circle"></i>使用中
                                </a>
                            </td>
                        </tr>
                        {% end %}

                    </tbody>
                </table>
                {% module Paginate(page_info['total'], page_info['page']) %}
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
</div>
<script type="text/javascript">
window.onload = function(){

    function set_status(t){
        data = ''
        for(var i = 0;i < $("input[name='select']").length;i++){
            if($("input[name='select']")[i].checked){
                data += $("input[name='select']")[i].value + ','
            }
        }
        if(data != ''){
            $.post("{{ reverse_url('box.set_istatus', page_info['page'], '') }}" + t,{data:data},function(result){
                window.location.href = '{{ reverse_url("box.index") }}page={{ page_info["page"] }}'
            });
        }
    }

    $('#status_ture').click(function(){
        set_status('1')
        
    })
    $('#status_false').click(function(){
        set_status('0')
    })
}
</script>
{% end%}